<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE ConstraintKinds   #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE ImplicitParams    #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LANGUAGE KindSignatures    #-}</span><span>
</span><span id="line-5"></span><span class="hs-pragma">{-# LANGUAGE PolyKinds         #-}</span><span>
</span><span id="line-6"></span><span class="hs-pragma">{-# LANGUAGE RankNTypes        #-}</span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE Trustworthy       #-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# OPTIONS_HADDOCK not-home #-}</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- we hide this module from haddock to enforce GHC.Stack as the main</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- access point.</span><span>
</span><span id="line-12"></span><span>
</span><span id="line-13"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Module      :  GHC.Stack.Types</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow 2015</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- License     :  see libraries/ghc-prim/LICENSE</span><span>
</span><span id="line-18"></span><span class="hs-comment">--</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- Maintainer  :  cvs-ghc@haskell.org</span><span>
</span><span id="line-20"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-21"></span><span class="hs-comment">-- Portability :  non-portable (GHC Extensions)</span><span>
</span><span id="line-22"></span><span class="hs-comment">--</span><span>
</span><span id="line-23"></span><span class="hs-comment">-- type definitions for implicit call-stacks.</span><span>
</span><span id="line-24"></span><span class="hs-comment">-- Use &quot;GHC.Stack&quot; from the base package instead of importing this</span><span>
</span><span id="line-25"></span><span class="hs-comment">-- module directly.</span><span>
</span><span id="line-26"></span><span class="hs-comment">--</span><span>
</span><span id="line-27"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Stack.Types</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-30"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Implicit call stacks</span></span><span>
</span><span id="line-31"></span><span>    </span><span class="annot"><a href="GHC.Stack.Types.html#CallStack"><span class="hs-identifier">CallStack</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier">HasCallStack</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>    </span><span class="annot"><a href="GHC.Stack.Types.html#emptyCallStack"><span class="hs-identifier">emptyCallStack</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#freezeCallStack"><span class="hs-identifier">freezeCallStack</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#fromCallSiteList"><span class="hs-identifier">fromCallSiteList</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>    </span><span class="annot"><a href="GHC.Stack.Types.html#getCallStack"><span class="hs-identifier">getCallStack</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#pushCallStack"><span class="hs-identifier">pushCallStack</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Source locations</span></span><span>
</span><span id="line-36"></span><span>    </span><span class="annot"><a href="GHC.Stack.Types.html#SrcLoc"><span class="hs-identifier">SrcLoc</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-37"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span class="hs-comment">{-
Ideally these would live in GHC.Stack but sadly they can't due to this
import cycle,

    Module imports form a cycle:
           module &#8216;GHC.Base&#8217; (libraries/base/GHC/Base.hs)
          imports &#8216;GHC.Err&#8217; (libraries/base/GHC/Err.hs)
    which imports &#8216;GHC.Stack&#8217; (libraries/base/dist-install/build/GHC/Stack.hs)
    which imports &#8216;GHC.Base&#8216; (libraries/base/GHC/Base.hs)
-}</span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Classes.html#"><span class="hs-identifier">GHC.Classes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier">Eq</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#"><span class="hs-identifier">GHC.Types</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier">Char</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier">Int</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-52"></span><span>
</span><span id="line-53"></span><span class="hs-comment">-- Make implicit dependency known to build system</span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Tuple.html#"><span class="hs-identifier">GHC.Tuple</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>       </span><span class="hs-comment">-- See Note [Depend on GHC.Tuple] in GHC.Base</span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#"><span class="hs-identifier">GHC.Num.Integer</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- See Note [Depend on GHC.Num.Integer] in GHC.Base</span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span class="hs-comment">----------------------------------------------------------------------</span><span>
</span><span id="line-58"></span><span class="hs-comment">-- Explicit call-stacks built via ImplicitParams</span><span>
</span><span id="line-59"></span><span class="hs-comment">----------------------------------------------------------------------</span><span>
</span><span id="line-60"></span><span>
</span><span id="line-61"></span><span class="hs-comment">-- | Request a CallStack.</span><span>
</span><span id="line-62"></span><span class="hs-comment">--</span><span>
</span><span id="line-63"></span><span class="hs-comment">-- NOTE: The implicit parameter @?callStack :: CallStack@ is an</span><span>
</span><span id="line-64"></span><span class="hs-comment">-- implementation detail and __should not__ be considered part of the</span><span>
</span><span id="line-65"></span><span class="hs-comment">-- 'CallStack' API, we may decide to change the implementation in the</span><span>
</span><span id="line-66"></span><span class="hs-comment">-- future.</span><span>
</span><span id="line-67"></span><span class="hs-comment">--</span><span>
</span><span id="line-68"></span><span class="hs-comment">-- @since 4.9.0.0</span><span>
</span><span id="line-69"></span><span class="hs-keyword">type</span><span> </span><span id="HasCallStack"><span class="annot"><a href="GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-var">HasCallStack</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="">?callStack</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#CallStack"><span class="hs-identifier hs-type">CallStack</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-70"></span><span>
</span><span id="line-71"></span><span class="hs-comment">-- | 'CallStack's are a lightweight method of obtaining a</span><span>
</span><span id="line-72"></span><span class="hs-comment">-- partial call-stack at any point in the program.</span><span>
</span><span id="line-73"></span><span class="hs-comment">--</span><span>
</span><span id="line-74"></span><span class="hs-comment">-- A function can request its call-site with the 'HasCallStack' constraint.</span><span>
</span><span id="line-75"></span><span class="hs-comment">-- For example, we can define</span><span>
</span><span id="line-76"></span><span class="hs-comment">--</span><span>
</span><span id="line-77"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-78"></span><span class="hs-comment">-- putStrLnWithCallStack :: HasCallStack =&gt; String -&gt; IO ()</span><span>
</span><span id="line-79"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-80"></span><span class="hs-comment">--</span><span>
</span><span id="line-81"></span><span class="hs-comment">-- as a variant of @putStrLn@ that will get its call-site and print it,</span><span>
</span><span id="line-82"></span><span class="hs-comment">-- along with the string given as argument. We can access the</span><span>
</span><span id="line-83"></span><span class="hs-comment">-- call-stack inside @putStrLnWithCallStack@ with 'GHC.Stack.callStack'.</span><span>
</span><span id="line-84"></span><span class="hs-comment">--</span><span>
</span><span id="line-85"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-86"></span><span class="hs-comment">-- putStrLnWithCallStack :: HasCallStack =&gt; String -&gt; IO ()</span><span>
</span><span id="line-87"></span><span class="hs-comment">-- putStrLnWithCallStack msg = do</span><span>
</span><span id="line-88"></span><span class="hs-comment">--   putStrLn msg</span><span>
</span><span id="line-89"></span><span class="hs-comment">--   putStrLn (prettyCallStack callStack)</span><span>
</span><span id="line-90"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-91"></span><span class="hs-comment">--</span><span>
</span><span id="line-92"></span><span class="hs-comment">-- Thus, if we call @putStrLnWithCallStack@ we will get a formatted call-stack</span><span>
</span><span id="line-93"></span><span class="hs-comment">-- alongside our string.</span><span>
</span><span id="line-94"></span><span class="hs-comment">--</span><span>
</span><span id="line-95"></span><span class="hs-comment">--</span><span>
</span><span id="line-96"></span><span class="hs-comment">-- &gt;&gt;&gt; putStrLnWithCallStack &quot;hello&quot;</span><span>
</span><span id="line-97"></span><span class="hs-comment">-- hello</span><span>
</span><span id="line-98"></span><span class="hs-comment">-- CallStack (from HasCallStack):</span><span>
</span><span id="line-99"></span><span class="hs-comment">--   putStrLnWithCallStack, called at &lt;interactive&gt;:2:1 in interactive:Ghci1</span><span>
</span><span id="line-100"></span><span class="hs-comment">--</span><span>
</span><span id="line-101"></span><span class="hs-comment">--</span><span>
</span><span id="line-102"></span><span class="hs-comment">-- GHC solves 'HasCallStack' constraints in three steps:</span><span>
</span><span id="line-103"></span><span class="hs-comment">--</span><span>
</span><span id="line-104"></span><span class="hs-comment">-- 1. If there is a 'CallStack' in scope -- i.e. the enclosing function</span><span>
</span><span id="line-105"></span><span class="hs-comment">--    has a 'HasCallStack' constraint -- GHC will append the new</span><span>
</span><span id="line-106"></span><span class="hs-comment">--    call-site to the existing 'CallStack'.</span><span>
</span><span id="line-107"></span><span class="hs-comment">--</span><span>
</span><span id="line-108"></span><span class="hs-comment">-- 2. If there is no 'CallStack' in scope -- e.g. in the GHCi session</span><span>
</span><span id="line-109"></span><span class="hs-comment">--    above -- and the enclosing definition does not have an explicit</span><span>
</span><span id="line-110"></span><span class="hs-comment">--    type signature, GHC will infer a 'HasCallStack' constraint for the</span><span>
</span><span id="line-111"></span><span class="hs-comment">--    enclosing definition (subject to the monomorphism restriction).</span><span>
</span><span id="line-112"></span><span class="hs-comment">--</span><span>
</span><span id="line-113"></span><span class="hs-comment">-- 3. If there is no 'CallStack' in scope and the enclosing definition</span><span>
</span><span id="line-114"></span><span class="hs-comment">--    has an explicit type signature, GHC will solve the 'HasCallStack'</span><span>
</span><span id="line-115"></span><span class="hs-comment">--    constraint for the singleton 'CallStack' containing just the</span><span>
</span><span id="line-116"></span><span class="hs-comment">--    current call-site.</span><span>
</span><span id="line-117"></span><span class="hs-comment">--</span><span>
</span><span id="line-118"></span><span class="hs-comment">-- 'CallStack's do not interact with the RTS and do not require compilation</span><span>
</span><span id="line-119"></span><span class="hs-comment">-- with @-prof@. On the other hand, as they are built up explicitly via the</span><span>
</span><span id="line-120"></span><span class="hs-comment">-- 'HasCallStack' constraints, they will generally not contain as much</span><span>
</span><span id="line-121"></span><span class="hs-comment">-- information as the simulated call-stacks maintained by the RTS.</span><span>
</span><span id="line-122"></span><span class="hs-comment">--</span><span>
</span><span id="line-123"></span><span class="hs-comment">-- A 'CallStack' is a @[(String, SrcLoc)]@. The @String@ is the name of</span><span>
</span><span id="line-124"></span><span class="hs-comment">-- function that was called, the 'SrcLoc' is the call-site. The list is</span><span>
</span><span id="line-125"></span><span class="hs-comment">-- ordered with the most recently called function at the head.</span><span>
</span><span id="line-126"></span><span class="hs-comment">--</span><span>
</span><span id="line-127"></span><span class="hs-comment">-- NOTE: The intrepid user may notice that 'HasCallStack' is just an</span><span>
</span><span id="line-128"></span><span class="hs-comment">-- alias for an implicit parameter @?callStack :: CallStack@. This is an</span><span>
</span><span id="line-129"></span><span class="hs-comment">-- implementation detail and __should not__ be considered part of the</span><span>
</span><span id="line-130"></span><span class="hs-comment">-- 'CallStack' API, we may decide to change the implementation in the</span><span>
</span><span id="line-131"></span><span class="hs-comment">-- future.</span><span>
</span><span id="line-132"></span><span class="hs-comment">--</span><span>
</span><span id="line-133"></span><span class="hs-comment">-- @since 4.8.1.0</span><span>
</span><span id="line-134"></span><span class="hs-keyword">data</span><span> </span><span id="CallStack"><span class="annot"><a href="GHC.Stack.Types.html#CallStack"><span class="hs-identifier hs-var">CallStack</span></a></span></span><span>
</span><span id="line-135"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="EmptyCallStack"><span class="annot"><a href="GHC.Stack.Types.html#EmptyCallStack"><span class="hs-identifier hs-var">EmptyCallStack</span></a></span></span><span>
</span><span id="line-136"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="PushCallStack"><span class="annot"><a href="GHC.Stack.Types.html#PushCallStack"><span class="hs-identifier hs-var">PushCallStack</span></a></span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#SrcLoc"><span class="hs-identifier hs-type">SrcLoc</span></a></span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#CallStack"><span class="hs-identifier hs-type">CallStack</span></a></span><span>
</span><span id="line-137"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="FreezeCallStack"><span class="annot"><a href="GHC.Stack.Types.html#FreezeCallStack"><span class="hs-identifier hs-var">FreezeCallStack</span></a></span></span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#CallStack"><span class="hs-identifier hs-type">CallStack</span></a></span><span>
</span><span id="line-138"></span><span>    </span><span class="hs-comment">-- ^ Freeze the stack at the given @CallStack@, preventing any further</span><span>
</span><span id="line-139"></span><span>    </span><span class="hs-comment">-- call-sites from being pushed onto it.</span><span>
</span><span id="line-140"></span><span>
</span><span id="line-141"></span><span>  </span><span class="hs-comment">-- See Note [Overview of implicit CallStacks]</span><span>
</span><span id="line-142"></span><span>
</span><span id="line-143"></span><span class="hs-comment">-- | Extract a list of call-sites from the 'CallStack'.</span><span>
</span><span id="line-144"></span><span class="hs-comment">--</span><span>
</span><span id="line-145"></span><span class="hs-comment">-- The list is ordered by most recent call.</span><span>
</span><span id="line-146"></span><span class="hs-comment">--</span><span>
</span><span id="line-147"></span><span class="hs-comment">-- @since 4.8.1.0</span><span>
</span><span id="line-148"></span><span class="annot"><a href="GHC.Stack.Types.html#getCallStack"><span class="hs-identifier hs-type">getCallStack</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#CallStack"><span class="hs-identifier hs-type">CallStack</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#SrcLoc"><span class="hs-identifier hs-type">SrcLoc</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-149"></span><span id="getCallStack"><span class="annot"><span class="annottext">getCallStack :: CallStack -&gt; [([Char], SrcLoc)]
</span><a href="GHC.Stack.Types.html#getCallStack"><span class="hs-identifier hs-var hs-var">getCallStack</span></a></span></span><span> </span><span id="local-6989586621679480830"><span class="annot"><span class="annottext">CallStack
</span><a href="#local-6989586621679480830"><span class="hs-identifier hs-var">stk</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CallStack
</span><a href="#local-6989586621679480830"><span class="hs-identifier hs-var">stk</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-150"></span><span>  </span><span class="annot"><span class="annottext">CallStack
</span><a href="GHC.Stack.Types.html#EmptyCallStack"><span class="hs-identifier hs-var">EmptyCallStack</span></a></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-151"></span><span>  </span><span class="annot"><a href="GHC.Stack.Types.html#PushCallStack"><span class="hs-identifier hs-type">PushCallStack</span></a></span><span> </span><span id="local-6989586621679480829"><span class="annot"><span class="annottext">[Char]
</span><a href="#local-6989586621679480829"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span id="local-6989586621679480828"><span class="annot"><span class="annottext">SrcLoc
</span><a href="#local-6989586621679480828"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621679480827"><span class="annot"><span class="annottext">CallStack
</span><a href="#local-6989586621679480827"><span class="hs-identifier hs-var">stk'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Char]
</span><a href="#local-6989586621679480829"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">SrcLoc
</span><a href="#local-6989586621679480828"><span class="hs-identifier hs-var">loc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Char], SrcLoc) -&gt; [([Char], SrcLoc)] -&gt; [([Char], SrcLoc)]
forall a. a -&gt; [a] -&gt; [a]
</span><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-var">:</span></a></span><span> </span><span class="annot"><span class="annottext">CallStack -&gt; [([Char], SrcLoc)]
</span><a href="GHC.Stack.Types.html#getCallStack"><span class="hs-identifier hs-var">getCallStack</span></a></span><span> </span><span class="annot"><span class="annottext">CallStack
</span><a href="#local-6989586621679480827"><span class="hs-identifier hs-var">stk'</span></a></span><span>
</span><span id="line-152"></span><span>  </span><span class="annot"><a href="GHC.Stack.Types.html#FreezeCallStack"><span class="hs-identifier hs-type">FreezeCallStack</span></a></span><span> </span><span id="local-6989586621679480826"><span class="annot"><span class="annottext">CallStack
</span><a href="#local-6989586621679480826"><span class="hs-identifier hs-var">stk'</span></a></span></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CallStack -&gt; [([Char], SrcLoc)]
</span><a href="GHC.Stack.Types.html#getCallStack"><span class="hs-identifier hs-var">getCallStack</span></a></span><span> </span><span class="annot"><span class="annottext">CallStack
</span><a href="#local-6989586621679480826"><span class="hs-identifier hs-var">stk'</span></a></span><span>
</span><span id="line-153"></span><span>
</span><span id="line-154"></span><span class="hs-comment">-- | Convert a list of call-sites to a 'CallStack'.</span><span>
</span><span id="line-155"></span><span class="hs-comment">--</span><span>
</span><span id="line-156"></span><span class="hs-comment">-- @since 4.9.0.0</span><span>
</span><span id="line-157"></span><span class="annot"><a href="GHC.Stack.Types.html#fromCallSiteList"><span class="hs-identifier hs-type">fromCallSiteList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#SrcLoc"><span class="hs-identifier hs-type">SrcLoc</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#CallStack"><span class="hs-identifier hs-type">CallStack</span></a></span><span>
</span><span id="line-158"></span><span id="fromCallSiteList"><span class="annot"><span class="annottext">fromCallSiteList :: [([Char], SrcLoc)] -&gt; CallStack
</span><a href="GHC.Stack.Types.html#fromCallSiteList"><span class="hs-identifier hs-var hs-var">fromCallSiteList</span></a></span></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621679480825"><span class="annot"><span class="annottext">[Char]
</span><a href="#local-6989586621679480825"><span class="hs-identifier hs-var">fn</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679480824"><span class="annot"><span class="annottext">SrcLoc
</span><a href="#local-6989586621679480824"><span class="hs-identifier hs-var">loc</span></a></span></span><span class="hs-special">)</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679480823"><span class="annot"><span class="annottext">[([Char], SrcLoc)]
</span><a href="#local-6989586621679480823"><span class="hs-identifier hs-var">cs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; SrcLoc -&gt; CallStack -&gt; CallStack
</span><a href="GHC.Stack.Types.html#PushCallStack"><span class="hs-identifier hs-var">PushCallStack</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><a href="#local-6989586621679480825"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">SrcLoc
</span><a href="#local-6989586621679480824"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[([Char], SrcLoc)] -&gt; CallStack
</span><a href="GHC.Stack.Types.html#fromCallSiteList"><span class="hs-identifier hs-var">fromCallSiteList</span></a></span><span> </span><span class="annot"><span class="annottext">[([Char], SrcLoc)]
</span><a href="#local-6989586621679480823"><span class="hs-identifier hs-var">cs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-159"></span><span class="annot"><a href="GHC.Stack.Types.html#fromCallSiteList"><span class="hs-identifier hs-var">fromCallSiteList</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CallStack
</span><a href="GHC.Stack.Types.html#EmptyCallStack"><span class="hs-identifier hs-var">EmptyCallStack</span></a></span><span>
</span><span id="line-160"></span><span>
</span><span id="line-161"></span><span class="hs-comment">-- Note [Definition of CallStack]</span><span>
</span><span id="line-162"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-163"></span><span class="hs-comment">-- CallStack is defined very early in base because it is</span><span>
</span><span id="line-164"></span><span class="hs-comment">-- used by error and undefined. At this point in the dependency graph,</span><span>
</span><span id="line-165"></span><span class="hs-comment">-- we do not have enough functionality to (conveniently) write a nice</span><span>
</span><span id="line-166"></span><span class="hs-comment">-- pretty-printer for CallStack. The sensible place to define the</span><span>
</span><span id="line-167"></span><span class="hs-comment">-- pretty-printer would be GHC.Stack, which is the main access point,</span><span>
</span><span id="line-168"></span><span class="hs-comment">-- but unfortunately GHC.Stack imports GHC.Exception, which *needs*</span><span>
</span><span id="line-169"></span><span class="hs-comment">-- the pretty-printer. So the CallStack type and functions are split</span><span>
</span><span id="line-170"></span><span class="hs-comment">-- between three modules:</span><span>
</span><span id="line-171"></span><span class="hs-comment">--</span><span>
</span><span id="line-172"></span><span class="hs-comment">-- 1. GHC.Stack.Types: defines the type and *simple* functions</span><span>
</span><span id="line-173"></span><span class="hs-comment">-- 2. GHC.Exception: defines the pretty-printer</span><span>
</span><span id="line-174"></span><span class="hs-comment">-- 3. GHC.Stack: exports everything and acts as the main access point</span><span>
</span><span id="line-175"></span><span>
</span><span id="line-176"></span><span>
</span><span id="line-177"></span><span class="hs-comment">-- | Push a call-site onto the stack.</span><span>
</span><span id="line-178"></span><span class="hs-comment">--</span><span>
</span><span id="line-179"></span><span class="hs-comment">-- This function has no effect on a frozen 'CallStack'.</span><span>
</span><span id="line-180"></span><span class="hs-comment">--</span><span>
</span><span id="line-181"></span><span class="hs-comment">-- @since 4.9.0.0</span><span>
</span><span id="line-182"></span><span class="annot"><a href="GHC.Stack.Types.html#pushCallStack"><span class="hs-identifier hs-type">pushCallStack</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#SrcLoc"><span class="hs-identifier hs-type">SrcLoc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#CallStack"><span class="hs-identifier hs-type">CallStack</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#CallStack"><span class="hs-identifier hs-type">CallStack</span></a></span><span>
</span><span id="line-183"></span><span id="pushCallStack"><span class="annot"><span class="annottext">pushCallStack :: ([Char], SrcLoc) -&gt; CallStack -&gt; CallStack
</span><a href="GHC.Stack.Types.html#pushCallStack"><span class="hs-identifier hs-var hs-var">pushCallStack</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679480822"><span class="annot"><span class="annottext">[Char]
</span><a href="#local-6989586621679480822"><span class="hs-identifier hs-var">fn</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679480821"><span class="annot"><span class="annottext">SrcLoc
</span><a href="#local-6989586621679480821"><span class="hs-identifier hs-var">loc</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679480820"><span class="annot"><span class="annottext">CallStack
</span><a href="#local-6989586621679480820"><span class="hs-identifier hs-var">stk</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CallStack
</span><a href="#local-6989586621679480820"><span class="hs-identifier hs-var">stk</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-184"></span><span>  </span><span class="annot"><a href="GHC.Stack.Types.html#FreezeCallStack"><span class="hs-identifier hs-type">FreezeCallStack</span></a></span><span> </span><span class="annot"><span class="annottext">CallStack
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CallStack
</span><a href="#local-6989586621679480820"><span class="hs-identifier hs-var">stk</span></a></span><span>
</span><span id="line-185"></span><span>  </span><span class="annot"><span class="annottext">CallStack
</span><span class="hs-identifier">_</span></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; SrcLoc -&gt; CallStack -&gt; CallStack
</span><a href="GHC.Stack.Types.html#PushCallStack"><span class="hs-identifier hs-var">PushCallStack</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><a href="#local-6989586621679480822"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">SrcLoc
</span><a href="#local-6989586621679480821"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">CallStack
</span><a href="#local-6989586621679480820"><span class="hs-identifier hs-var">stk</span></a></span><span>
</span><span id="line-186"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#pushCallStack"><span class="hs-pragma hs-type">pushCallStack</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-187"></span><span>
</span><span id="line-188"></span><span>
</span><span id="line-189"></span><span class="hs-comment">-- | The empty 'CallStack'.</span><span>
</span><span id="line-190"></span><span class="hs-comment">--</span><span>
</span><span id="line-191"></span><span class="hs-comment">-- @since 4.9.0.0</span><span>
</span><span id="line-192"></span><span class="annot"><a href="GHC.Stack.Types.html#emptyCallStack"><span class="hs-identifier hs-type">emptyCallStack</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#CallStack"><span class="hs-identifier hs-type">CallStack</span></a></span><span>
</span><span id="line-193"></span><span id="emptyCallStack"><span class="annot"><span class="annottext">emptyCallStack :: CallStack
</span><a href="GHC.Stack.Types.html#emptyCallStack"><span class="hs-identifier hs-var hs-var">emptyCallStack</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CallStack
</span><a href="GHC.Stack.Types.html#EmptyCallStack"><span class="hs-identifier hs-var">EmptyCallStack</span></a></span><span>
</span><span id="line-194"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#emptyCallStack"><span class="hs-pragma hs-type">emptyCallStack</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-195"></span><span>
</span><span id="line-196"></span><span>
</span><span id="line-197"></span><span class="hs-comment">-- | Freeze a call-stack, preventing any further call-sites from being appended.</span><span>
</span><span id="line-198"></span><span class="hs-comment">--</span><span>
</span><span id="line-199"></span><span class="hs-comment">-- prop&gt; pushCallStack callSite (freezeCallStack callStack) = freezeCallStack callStack</span><span>
</span><span id="line-200"></span><span class="hs-comment">--</span><span>
</span><span id="line-201"></span><span class="hs-comment">-- @since 4.9.0.0</span><span>
</span><span id="line-202"></span><span class="annot"><a href="GHC.Stack.Types.html#freezeCallStack"><span class="hs-identifier hs-type">freezeCallStack</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#CallStack"><span class="hs-identifier hs-type">CallStack</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#CallStack"><span class="hs-identifier hs-type">CallStack</span></a></span><span>
</span><span id="line-203"></span><span id="freezeCallStack"><span class="annot"><span class="annottext">freezeCallStack :: CallStack -&gt; CallStack
</span><a href="GHC.Stack.Types.html#freezeCallStack"><span class="hs-identifier hs-var hs-var">freezeCallStack</span></a></span></span><span> </span><span id="local-6989586621679480819"><span class="annot"><span class="annottext">CallStack
</span><a href="#local-6989586621679480819"><span class="hs-identifier hs-var">stk</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CallStack -&gt; CallStack
</span><a href="GHC.Stack.Types.html#FreezeCallStack"><span class="hs-identifier hs-var">FreezeCallStack</span></a></span><span> </span><span class="annot"><span class="annottext">CallStack
</span><a href="#local-6989586621679480819"><span class="hs-identifier hs-var">stk</span></a></span><span>
</span><span id="line-204"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html#freezeCallStack"><span class="hs-pragma hs-type">freezeCallStack</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-205"></span><span>
</span><span id="line-206"></span><span>
</span><span id="line-207"></span><span class="hs-comment">-- | A single location in the source code.</span><span>
</span><span id="line-208"></span><span class="hs-comment">--</span><span>
</span><span id="line-209"></span><span class="hs-comment">-- @since 4.8.1.0</span><span>
</span><span id="line-210"></span><span class="hs-keyword">data</span><span> </span><span id="SrcLoc"><span class="annot"><a href="GHC.Stack.Types.html#SrcLoc"><span class="hs-identifier hs-var">SrcLoc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="SrcLoc"><span class="annot"><a href="GHC.Stack.Types.html#SrcLoc"><span class="hs-identifier hs-var">SrcLoc</span></a></span></span><span>
</span><span id="line-211"></span><span>  </span><span class="hs-special">{</span><span> </span><span id="srcLocPackage"><span class="annot"><span class="annottext">SrcLoc -&gt; [Char]
</span><a href="GHC.Stack.Types.html#srcLocPackage"><span class="hs-identifier hs-var hs-var">srcLocPackage</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-212"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="srcLocModule"><span class="annot"><span class="annottext">SrcLoc -&gt; [Char]
</span><a href="GHC.Stack.Types.html#srcLocModule"><span class="hs-identifier hs-var hs-var">srcLocModule</span></a></span></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-213"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="srcLocFile"><span class="annot"><span class="annottext">SrcLoc -&gt; [Char]
</span><a href="GHC.Stack.Types.html#srcLocFile"><span class="hs-identifier hs-var hs-var">srcLocFile</span></a></span></span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-214"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="srcLocStartLine"><span class="annot"><span class="annottext">SrcLoc -&gt; Int
</span><a href="GHC.Stack.Types.html#srcLocStartLine"><span class="hs-identifier hs-var hs-var">srcLocStartLine</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-215"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="srcLocStartCol"><span class="annot"><span class="annottext">SrcLoc -&gt; Int
</span><a href="GHC.Stack.Types.html#srcLocStartCol"><span class="hs-identifier hs-var hs-var">srcLocStartCol</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-216"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="srcLocEndLine"><span class="annot"><span class="annottext">SrcLoc -&gt; Int
</span><a href="GHC.Stack.Types.html#srcLocEndLine"><span class="hs-identifier hs-var hs-var">srcLocEndLine</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-217"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="srcLocEndCol"><span class="annot"><span class="annottext">SrcLoc -&gt; Int
</span><a href="GHC.Stack.Types.html#srcLocEndCol"><span class="hs-identifier hs-var hs-var">srcLocEndCol</span></a></span></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-218"></span><span>  </span><span class="hs-special">}</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span id="local-6989586621679480798"><span id="local-6989586621679480810"><span class="annot"><span class="annottext">SrcLoc -&gt; SrcLoc -&gt; Bool
(SrcLoc -&gt; SrcLoc -&gt; Bool)
-&gt; (SrcLoc -&gt; SrcLoc -&gt; Bool) -&gt; Eq SrcLoc
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: SrcLoc -&gt; SrcLoc -&gt; Bool
$c/= :: SrcLoc -&gt; SrcLoc -&gt; Bool
== :: SrcLoc -&gt; SrcLoc -&gt; Bool
$c== :: SrcLoc -&gt; SrcLoc -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></a></span></span></span><span> </span><span class="hs-comment">-- ^ @since 4.9.0.0</span><span>
</span><span id="line-219"></span></pre></body></html>